﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine.Playables;
using UnityEngine;
using UnityEngine.Timeline;

//Timeline应该是一个叠起来的架构
//等同于TimelinePlayable

public class MiaolinePlayable : PlayableBehaviour
{

    public static ScriptPlayable<MiaolinePlayable> Create(PlayableGraph graph, IEnumerable<TrackAsset> tracks, GameObject go, bool autoRebalance, bool createOutputs)
    {
        if (tracks == null)
            throw new ArgumentNullException("Tracks list is null", "tracks");

        if (go == null)
            throw new ArgumentNullException("GameObject parameter is null", "go");

        var playable = ScriptPlayable<MiaolinePlayable>.Create(graph);
        playable.SetTraversalMode(PlayableTraversalMode.Passthrough);
        var sequence = playable.GetBehaviour();
        //sequence.Compile()
        return playable;
    }

    public void Compile(PlayableGraph graph, Playable timelinePlayable, IEnumerable<TrackAsset> tracks, GameObject go, bool autoRebalance, bool createOutputs)
    {
        if (tracks == null)
            throw new ArgumentNullException("Tracks list is null", "tracks");

        if (go == null)
            throw new ArgumentNullException("GameObject parameter is null", "go");

        var outputTrackList = new List<TrackAsset>(tracks);
        var maximumNumberOfIntersections = outputTrackList.Count * 2 + outputTrackList.Count; // worse case: 2 overlapping clips per track + each track
        //m_CurrentListOfActiveClips = new List<RuntimeElement>(maximumNumberOfIntersections);
        //m_ActiveClips = new List<RuntimeElement>(maximumNumberOfIntersections);

    }


    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        base.ProcessFrame(playable, info, playerData);

        Debug.Log("Test");
    }

}

